import fetch from 'utils/fetch';

// 获取所有角色
export function listEmployeeRole() {
    return fetch({
        url:'/employee/listEmployeeRole',
        method: 'post'
    });
}

// 添加员工
export function insertEmployee(account,username,phone,roleId) {
    const data = {
        account,
        username,
        phone,
        roleId
    };
    return fetch({
        url:'/employee/insertEmployee',
        method: 'post',
        data
    });
}


// 修改员工
export function updateEmployee(username,phone,roleId,employeeId) {
    const data = {
        username,
        phone,
        roleId,
        employeeId
    };
    return fetch({
        url:'/employee/updateEmployee',
        method: 'post',
        data
    });
}

// 初始化密码
export function updatePassword(employeeId) {
    const data = {
        employeeId
    };
    return fetch({
        url:'/employee/updatePassword',
        method: 'post',
        data
    });
}

// 禁用启用
export function updateEmployeeStatus(employeeId,status) {
    const data = {
        employeeId,
        status
    };
    return fetch({
        url:'/employee/updateEmployeeStatus',
        method: 'post',
        data
    });
}

// 分页查询
export function listEmployeeByCondition(account,username,phone,roleId,curPage,pageSize) {
    const data = {
        account,
        username,
        phone,
        roleId,
        curPage,
        pageSize
    };
    return fetch({
        url:'/employee/listEmployeeByCondition',
        method: 'post',
        data
    });
}

// 判断用户名是否重名
export function checkCount(account) {
    const data = {
        account
    };
    return fetch({
        url:'/employee/employeeNameValidate',
        method: 'post',
        data
    });
}